home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Windows 95 Programs / Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso / 1473 / form1.frm < prev    next >
Text File  |  1997-03-06  |  10KB  |  348 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "AD7896 Setup"
  4.    ClientHeight    =   4200
  5.    ClientLeft      =   1992
  6.    ClientTop       =   3048
  7.    ClientWidth     =   4704
  8.    Height          =   4524
  9.    Icon            =   "Form1.frx":0000
  10.    Left            =   1944
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   4200
  13.    ScaleWidth      =   4704
  14.    Top             =   2772
  15.    Width           =   4800
  16.    Begin VB.CommandButton Command1 
  17.       Caption         =   "E&xit"
  18.       Height          =   375
  19.       Left            =   3600
  20.       TabIndex        =   18
  21.       Top             =   2040
  22.       Width           =   855
  23.    End
  24.    Begin VB.TextBox Text1 
  25.       Alignment       =   2  'Center
  26.       BackColor       =   &H00FF0000&
  27.       BeginProperty Font 
  28.          name            =   "MS Sans Serif"
  29.          charset         =   0
  30.          weight          =   400
  31.          size            =   9.6
  32.          underline       =   0   'False
  33.          italic          =   0   'False
  34.          strikethrough   =   0   'False
  35.       EndProperty
  36.       ForeColor       =   &H0000FFFF&
  37.       Height          =   615
  38.       Left            =   600
  39.       MultiLine       =   -1  'True
  40.       TabIndex        =   17
  41.       Text            =   "Form1.frx":0442
  42.       Top             =   3480
  43.       Width           =   3855
  44.    End
  45.    Begin VB.CommandButton Start 
  46.       Caption         =   "&Start"
  47.       Height          =   375
  48.       Left            =   3600
  49.       TabIndex        =   8
  50.       Top             =   2760
  51.       Width           =   855
  52.    End
  53.    Begin VB.TextBox Interval 
  54.       BackColor       =   &H00C00000&
  55.       BeginProperty Font 
  56.          name            =   "MS Sans Serif"
  57.          charset         =   0
  58.          weight          =   700
  59.          size            =   7.8
  60.          underline       =   0   'False
  61.          italic          =   0   'False
  62.          strikethrough   =   0   'False
  63.       EndProperty
  64.       ForeColor       =   &H0000FFFF&
  65.       Height          =   375
  66.       Left            =   2640
  67.       TabIndex        =   7
  68.       Text            =   "1000"
  69.       Top             =   2160
  70.       Width           =   615
  71.    End
  72.    Begin VB.TextBox DataReadBit 
  73.       BackColor       =   &H00C00000&
  74.       BeginProperty Font 
  75.          name            =   "MS Sans Serif"
  76.          charset         =   0
  77.          weight          =   700
  78.          size            =   7.8
  79.          underline       =   0   'False
  80.          italic          =   0   'False
  81.          strikethrough   =   0   'False
  82.       EndProperty
  83.       ForeColor       =   &H0000FFFF&
  84.       Height          =   285
  85.       Left            =   2640
  86.       TabIndex        =   6
  87.       Text            =   "0"
  88.       Top             =   1800
  89.       Width           =   255
  90.    End
  91.    Begin VB.PictureBox Picture1 
  92.       Height          =   612
  93.       Left            =   120
  94.       Picture         =   "Form1.frx":0482
  95.       ScaleHeight     =   564
  96.       ScaleWidth      =   564
  97.       TabIndex        =   0
  98.       Top             =   120
  99.       Width           =   612
  100.    End
  101.    Begin VB.TextBox ConvertBit 
  102.       BackColor       =   &H00C00000&
  103.       BeginProperty Font 
  104.          name            =   "MS Sans Serif"
  105.          charset         =   0
  106.          weight          =   700
  107.          size            =   7.8
  108.          underline       =   0   'False
  109.          italic          =   0   'False
  110.          strikethrough   =   0   'False
  111.       EndProperty
  112.       ForeColor       =   &H0000FFFF&
  113.       Height          =   285
  114.       Left            =   2640
  115.       TabIndex        =   5
  116.       Text            =   "0"
  117.       Top             =   1440
  118.       Width           =   255
  119.    End
  120.    Begin VB.TextBox ClockBit 
  121.       BackColor       =   &H00C00000&
  122.       BeginProperty Font 
  123.          name            =   "MS Sans Serif"
  124.          charset         =   0
  125.          weight          =   700
  126.          size            =   7.8
  127.          underline       =   0   'False
  128.          italic          =   0   'False
  129.          strikethrough   =   0   'False
  130.       EndProperty
  131.       ForeColor       =   &H0000FFFF&
  132.       Height          =   285
  133.       Left            =   2640
  134.       TabIndex        =   4
  135.       Text            =   "0"
  136.       Top             =   1080
  137.       Width           =   255
  138.    End
  139.    Begin VB.TextBox PortReadAddress 
  140.       BackColor       =   &H00C00000&
  141.       BeginProperty Font 
  142.          name            =   "MS Sans Serif"
  143.          charset         =   0
  144.          weight          =   700
  145.          size            =   7.8
  146.          underline       =   0   'False
  147.          italic          =   0   'False
  148.          strikethrough   =   0   'False
  149.       EndProperty
  150.       ForeColor       =   &H0000FFFF&
  151.       Height          =   285
  152.       Left            =   2640
  153.       TabIndex        =   3
  154.       Text            =   "889"
  155.       Top             =   720
  156.       Width           =   615
  157.    End
  158.    Begin VB.TextBox PortWriteAddress 
  159.       Alignment       =   2  'Center
  160.       BackColor       =   &H00C00000&
  161.       BeginProperty Font 
  162.          name            =   "MS Sans Serif"
  163.          charset         =   0
  164.          weight          =   700
  165.          size            =   7.8
  166.          underline       =   0   'False
  167.          italic          =   0   'False
  168.          strikethrough   =   0   'False
  169.       EndProperty
  170.       ForeColor       =   &H0000FFFF&
  171.       Height          =   285
  172.       Left            =   2640
  173.       TabIndex        =   2
  174.       Text            =   "888"
  175.       Top             =   360
  176.       Width           =   615
  177.    End
  178.    Begin VB.TextBox Analogue 
  179.       BackColor       =   &H00C00000&
  180.       BeginProperty Font 
  181.          name            =   "MS Sans Serif"
  182.          charset         =   0
  183.          weight          =   700
  184.          size            =   7.8
  185.          underline       =   0   'False
  186.          italic          =   0   'False
  187.          strikethrough   =   0   'False
  188.       EndProperty
  189.       ForeColor       =   &H0000FFFF&
  190.       Height          =   375
  191.       Left            =   2640
  192.       TabIndex        =   9
  193.       Top             =   2760
  194.       Width           =   615
  195.    End
  196.    Begin VB.Label Label7 
  197.       Caption         =   "Interval Timer"
  198.       Height          =   252
  199.       Left            =   1200
  200.       TabIndex        =   16
  201.       Top             =   2160
  202.       Width           =   1212
  203.    End
  204.    Begin VB.Label Label6 
  205.       Caption         =   "Analogue Value"
  206.       Height          =   252
  207.       Left            =   1200
  208.       TabIndex        =   15
  209.       Top             =   2880
  210.       Width           =   1212
  211.    End
  212.    Begin VB.Label Label5 
  213.       Caption         =   "Data Read Bit"
  214.       Height          =   252
  215.       Left            =   1200
  216.       TabIndex        =   14
  217.       Top             =   1800
  218.       Width           =   1332
  219.    End
  220.    Begin VB.Label Label4 
  221.       Caption         =   "Convert Bit"
  222.       Height          =   252
  223.       Left            =   1200
  224.       TabIndex        =   13
  225.       Top             =   1440
  226.       Width           =   1332
  227.    End
  228.    Begin VB.Label Label3 
  229.       Caption         =   "Clock Bit"
  230.       Height          =   252
  231.       Left            =   1200
  232.       TabIndex        =   12
  233.       Top             =   1080
  234.       Width           =   1332
  235.    End
  236.    Begin VB.Label Label2 
  237.       Caption         =   "Port Read Address"
  238.       Height          =   252
  239.       Left            =   1200
  240.       TabIndex        =   11
  241.       Top             =   720
  242.       Width           =   1572
  243.    End
  244.    Begin VB.Label Label1 
  245.       Caption         =   "Port Write Address"
  246.       Height          =   252
  247.       Left            =   1200
  248.       TabIndex        =   10
  249.       Top             =   360
  250.       Width           =   1572
  251.    End
  252.    Begin AD7896Lib.AD7896 AD7896 
  253.       Height          =   600
  254.       Left            =   120
  255.       TabIndex        =   1
  256.       Top             =   2160
  257.       Width           =   600
  258.       _Version        =   65536
  259.       _ExtentX        =   1058
  260.       _ExtentY        =   1058
  261.       _StockProps     =   0
  262.       ClockBit        =   8
  263.       ConvertBit      =   4
  264.       DataReadBit     =   7
  265.    End
  266. End
  267. Attribute VB_Name = "Form1"
  268. Attribute VB_Creatable = False
  269. Attribute VB_Exposed = False
  270. Private Sub AD7896_Timer()
  271. Dim Data
  272. Data = AD7896.Read
  273.  
  274. ' The constant is used to convert the 12 bit data to a voltage.
  275. ' The constant is based on the supply/reference voltage of 5v (5v/4096)
  276.  
  277. Analogue.Text = Format$((Data * 0.001221001221001), "#0.00")
  278. End Sub
  279.  
  280. Private Sub Analogue_Change()
  281.  
  282. End Sub
  283.  
  284.  
  285. Private Sub Command1_Click()
  286.  
  287. End
  288.  
  289. End Sub
  290.  
  291.  
  292. Private Sub Form_Load()
  293.  
  294. Show
  295. AD7896.EnableTimer = False
  296. End Sub
  297.  
  298.  
  299. Private Sub Text2_Change()
  300.  
  301. End Sub
  302.  
  303.  
  304. Private Sub Start_Click()
  305. Static Toggle%
  306.  
  307.  
  308. Toggle% = Toggle% Xor 1
  309.  
  310. If Toggle% = 1 Then
  311.     ' read the various port and bit settings into the control
  312.     
  313.     AD7896.ReadPortAddress = PortReadAddress.Text
  314.     AD7896.WritePortAddress = PortWriteAddress.Text
  315.     AD7896.ClockBit = ClockBit.Text
  316.     AD7896.ConvertBit = ConvertBit.Text
  317.     AD7896.DataReadBit = DataReadBit.Text
  318.     AD7896.Interval = Interval.Text
  319.     AD7896.EnableTimer = True
  320.     
  321.     ' disable the port and bit selectors during reading
  322.     
  323.     PortReadAddress.Enabled = False
  324.     PortWriteAddress.Enabled = False
  325.     ClockBit.Enabled = False
  326.     ConvertBit.Enabled = False
  327.     DataReadBit.Enabled = False
  328.     Interval.Enabled = False
  329.     Start.Caption = "&Stop"
  330. Else
  331.     ' enable the port and bit settings
  332.     
  333.     AD7896.EnableTimer = False
  334.     PortReadAddress.Enabled = True
  335.     PortWriteAddress.Enabled = True
  336.     ClockBit.Enabled = True
  337.     ConvertBit.Enabled = True
  338.     DataReadBit.Enabled = True
  339.     Interval.Enabled = True
  340.     Start.Caption = "&Start"
  341.     Analogue.Text = ""
  342. End If
  343.  
  344.  
  345. End Sub
  346.  
  347.  
  348.